package com.shangxia.monomer.study.designPatterns.behavioralType.strategy;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: monomer
 * @ClassName: StrategyDemo
 * @Time: 2021/7/25
 * @Author: zhouy
 * @Description:
 * @Experience:
 */

@Slf4j
public class StrategyDemo {
    public static void main(String[] args) {
        List<Zombie> list = new ArrayList<>();
        list.add(new Zombie001("001"));
        list.add(new Zombie002("002"));
        list.add(new Zombie003("003"));
        for (Zombie zombie : list) {
            zombie.show();
            zombie.move();
            zombie.attach();
        }
    }
}

@AllArgsConstructor
@Data
abstract class Zombie {
    private String name;

    void show() {
        System.out.println("I am " + getName());
    }

    void move() {
    }

    void attach() {
    }
}

class Zombie001 extends Zombie {

    public Zombie001(String name) {
        super(name);
    }

    @Override
    void move() {
        System.out.println("走");
    }

    @Override
    void attach() {
        System.out.println("普通攻击");
    }
}

class Zombie002 extends Zombie {

    public Zombie002(String name) {
        super(name);
    }


    @Override
    void move() {
        System.out.println("飞");
    }

    @Override
    void attach() {
        System.out.println("普通攻击");
    }
}

class Zombie003 extends Zombie {

    public Zombie003(String name) {
        super(name);
    }


    @Override
    void move() {
        System.out.println("飞");
    }

    @Override
    void attach() {
        System.out.println("技能攻击");
    }
}
